//
//  SubjectAppView.m
//  LimitFree
//
//  Created by LZXuan on 15-6-27.
//  Copyright (c) 2015年 轩哥. All rights reserved.
//

#import "SubjectAppView.h"
#import "UIImageView+WebCache.h"

@interface SubjectAppView()
@property (nonatomic,weak) id target;
@property (nonatomic,assign) SEL action;
@end

@implementation SubjectAppView

- (void)awakeFromNib {
    //xib 初始化 调用
    //圆角
    self.iconImageView.layer.masksToBounds = YES;
    self.iconImageView.layer.cornerRadius = 5;
}

//增加一个点击事件
- (void)addTarget:(id)target action:(SEL)action {
    //UIView 默认可以和用户交互
    //保存
    self.target = target;
    self.action = action;
}
//手指离开当前视图的时候
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    //忽略SEL 产生的警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"

    if ([self.target respondsToSelector:self.action]) {
        //调用
        [self.target performSelector:self.action withObject:self];
    }
#pragma clang diagnostic pop
}
//填充内容
- (void)showDataWithModel:(AppModel *)model {
    self.nameLabel.text = model.name;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.iconUrl] placeholderImage:[UIImage imageNamed: @"topic_Header"]];
    self.commentLabel.text = model.comment.stringValue;
    self.downloadLabel.text = model.downloads;
    [self.starView setStarLevel:model.starOverall.doubleValue];
}

@end




